#pragma once

#include "CFWrapper.h"

class CFileReader : public IFileReader
{
public:
	CFileReader(const CF_CALLBACK_INFO *pCallbackInfo, LockExit lockExit, std::wstring strFileName);
	~CFileReader();

	INT64 GetKey() const override;
	void Cancel() override;
	bool IsCanceled() const override { return m_bCanceled; }
	void OnOpen(INT64 nFileSize, FILETIME ftLastWrite) override;
	void OnRead(BufferPtr pBuffer, INT64 nOffset, size_t nLength) override;
	void OnError(INT64 nOffset, INT64 nLength) override;

private:
	std::atomic_bool m_bCanceled;
	CF::CCbWrapper   m_cfCbWrapper;
	LockExit         m_lockExit;	// Prevent CloudManager from exiting
	std::wstring     m_strFileName;
	INT64            m_nFileSize;
};
